//
//  GuidePageView.swift
//  TravelNotes
//
//  Created by 千锋 on 16/8/15.
//  Copyright © 2016年 胡光健. All rights reserved.
//

import UIKit

class GuidePageView: UIView {

    var scrollView: UIScrollView?
    var goInButton: UIButton?

    init(frame: CGRect, imageArray: NSArray) {
        super.init(frame: frame)
        
        self.scrollView = UIScrollView(frame: CGRectMake(0, 0,screenWidth, screenHeight+64))
        
        self.scrollView?.pagingEnabled = true
        
        self.scrollView?.showsHorizontalScrollIndicator = false
        self.addSubview(self.scrollView!)
        
        self.scrollView?.contentSize = CGSizeMake(CGFloat(imageArray.count) * screenWidth, 0)
        
        for i in 0..<imageArray.count {
            let imageView = Factory.createImageViewWith(CGRectMake(CGFloat(i) * screenWidth, 0, screenWidth, screenHeight + 64), imageName: imageArray[i] as! String)
            
            imageView.userInteractionEnabled = true
            
            self.scrollView?.addSubview(imageView)
            
            
            if i == imageArray.count - 1 {
                self.goInButton = UIButton(type: .Custom)
                self.goInButton?.frame = CGRectMake(300, 180, 60, 60)
                self.goInButton?.setImage(UIImage(named: ""), forState: .Normal)
                imageView.addSubview(self.goInButton!)
            }
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        
        fatalError("init(coder:) has not been implemented")
    }

}
